package com.nemo.fenxiangs.service.impl;

import java.util.List;

import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.nemo.fenxiangs.mapper.ItemsMapper;
import com.nemo.fenxiangs.mapper.ItemsMapperCustom;
import com.nemo.fenxiangs.po.Items;
import com.nemo.fenxiangs.po.ItemsCustom;
import com.nemo.fenxiangs.po.QueryItemsVo;
import com.nemo.fenxiangs.service.ItemsService;


public class ItemsServiceImpl implements ItemsService {

	@Autowired
	private ItemsMapperCustom itemsMapperCustom ;
	@Autowired
	private ItemsMapper itemsMapper ;
	@Override
	public List<ItemsCustom> findItemsList(QueryItemsVo queryItemsVo)throws Exception {
		return itemsMapperCustom.findItemsList(queryItemsVo);	
	}
	@Override
	public ItemsCustom findItemsById(Integer id) throws Exception {
		 Items items =itemsMapper.selectByPrimaryKey(id);
		
		 ItemsCustom itemsCustom =null;
		 if(items!=null){
			 itemsCustom = new ItemsCustom();
			 BeanUtils.copyProperties(items, itemsCustom );
		 }
		return itemsCustom ;
	}
	@Override
	public void updateItems(Integer id, ItemsCustom itemsCustom)
			throws Exception {
		itemsCustom.setId(id);
		itemsMapper.updateByPrimaryKeyWithBLOBs(itemsCustom);
	}
	@Override
	public void deleteByPrimaryKey(Integer id) throws Exception {
		// TODO Auto-generated method stub
		itemsMapper.deleteByPrimaryKey(id);
	}
	
	@Override
	public void insertItems(QueryItemsVo queryItemsVo) throws Exception {
		// TODO Auto-generated method stub
		itemsMapperCustom.insertItems(queryItemsVo);
	}
	@Override
	public int getProductsCount(QueryItemsVo queryItemsVo) throws Exception {
		// TODO Auto-generated method stub
		return itemsMapperCustom.getProductsCount(queryItemsVo);
	}
 
}
